

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>l5kit.data package &mdash; L5Kit 1.0.0 documentation</title>
  

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />

  
  
  
  

  
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="l5kit.data.proto package" href="l5kit.data.proto.html" />
    <link rel="prev" title="API Reference" href="../api_reference.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home" alt="Documentation Home"> L5Kit
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../README.html">ML Prediction, Planning and Simulation for Self-Driving</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#examples">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#news">News</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#overview">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#license">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#credits">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#contact">Contact</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../api_reference.html">API Reference</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">l5kit.data package</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#subpackages">Subpackages</a><ul>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.proto.html">l5kit.data.proto package</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#submodules">Submodules</a><ul>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.combine.html">l5kit.data.combine module</a></li>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.filter.html">l5kit.data.filter module</a></li>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.labels.html">l5kit.data.labels module</a></li>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.local_data_manager.html">l5kit.data.local_data_manager module</a></li>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.map.html">l5kit.data.map module</a></li>
<li class="toctree-l4"><a class="reference internal" href="l5kit.data.zarr_dataset.html">l5kit.data.zarr_dataset module</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.dataset.html">l5kit.dataset package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.evaluation.html">l5kit.evaluation package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.geometry.html">l5kit.geometry package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.kinematic.html">l5kit.kinematic package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.random.html">l5kit.random package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.sampling.html">l5kit.sampling package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.visualization.html">l5kit.visualization package</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../data_format.html">Dataset Formats</a></li>
<li class="toctree-l1"><a class="reference internal" href="../how_to_contribute.html">How to contribute</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">L5Kit</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../api_reference.html">API Reference</a> &raquo;</li>
        
      <li>l5kit.data package</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/API/l5kit.data.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-l5kit.data">
<span id="l5kit-data-package"></span><h1>l5kit.data package<a class="headerlink" href="#module-l5kit.data" title="Permalink to this headline">¶</a></h1>
<dl class="py class">
<dt id="l5kit.data.ChunkedStateDataset">
<em class="property">class </em><code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">ChunkedStateDataset</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">path</span><span class="p">:</span> <span class="n">str</span></em>, <em class="sig-param"><span class="n">key</span><span class="p">:</span> <span class="n">str</span> <span class="o">=</span> <span class="default_value">''</span></em><span class="sig-paren">)</span><a class="headerlink" href="#l5kit.data.ChunkedStateDataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>ChunkedDataSet is a dataset that lives on disk in compressed chunks, it has easy to use data loading and
writing interfaces that involves making numpy-like slices.</p>
<p>Currently only .zarr directory stores are supported (i.e. the data will live in a folder on your
local filesystem called &lt;something&gt;.zarr).</p>
<dl class="py method">
<dt id="l5kit.data.ChunkedStateDataset.initialize">
<code class="sig-name descname">initialize</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">mode</span><span class="p">:</span> <span class="n">str</span> <span class="o">=</span> <span class="default_value">'w'</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#l5kit.data.ChunkedStateDataset.initialize" title="Permalink to this definition">¶</a></dt>
<dd><p>Initializes a new zarr dataset, creating the underlying arrays.</p>
<dl class="field-list simple">
<dt class="field-odd">Keyword Arguments</dt>
<dd class="field-odd"><p><strong>mode</strong> (<em>str</em>) – Mode to open dataset in, should be something that supports writing. (default: {“w”})</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt id="l5kit.data.ChunkedStateDataset.open">
<code class="sig-name descname">open</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">mode</span><span class="p">:</span> <span class="n">str</span> <span class="o">=</span> <span class="default_value">'r'</span></em>, <em class="sig-param"><span class="n">cached</span><span class="p">:</span> <span class="n">bool</span> <span class="o">=</span> <span class="default_value">True</span></em>, <em class="sig-param"><span class="n">cache_size_bytes</span><span class="p">:</span> <span class="n">int</span> <span class="o">=</span> <span class="default_value">1000000000</span></em><span class="sig-paren">)</span> &#x2192; None<a class="headerlink" href="#l5kit.data.ChunkedStateDataset.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Opens a zarr dataset from disk from the path supplied in the constructor.</p>
<blockquote>
<div><dl class="simple">
<dt>Keyword Arguments:</dt><dd><p>mode (str): Mode to open dataset in, default to read-only (default: {“r”})
cached (bool): Whether to cache files read from disk using a LRU cache. (default: {True})
cache_size (int): Size of cache in bytes (default: {1e9} (1GB))</p>
</dd>
<dt>Raises:</dt><dd><p>Exception: When any of the expected arrays (frames, agents, scenes) is missing or the store couldn’t be</p>
</dd>
</dl>
</div></blockquote>
<p>opened.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="l5kit.data.DataManager">
<em class="property">class </em><code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">DataManager</code><a class="headerlink" href="#l5kit.data.DataManager" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">abc.ABC</span></code></p>
<dl class="py method">
<dt id="l5kit.data.DataManager.require">
<em class="property">abstract </em><code class="sig-name descname">require</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; str<a class="headerlink" href="#l5kit.data.DataManager.require" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="py class">
<dt id="l5kit.data.LocalDataManager">
<em class="property">class </em><code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">LocalDataManager</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">local_data_folder</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>Union<span class="p">[</span>str<span class="p">, </span>pathlib.Path<span class="p">]</span><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="headerlink" href="#l5kit.data.LocalDataManager" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="l5kit.data.local_data_manager.html#l5kit.data.local_data_manager.DataManager" title="l5kit.data.local_data_manager.DataManager"><code class="xref py py-class docutils literal notranslate"><span class="pre">l5kit.data.local_data_manager.DataManager</span></code></a></p>
<p>LocalDataManager allows you to require data to be present in the subpath of a specific folder.</p>
<p>Example:
Your data folder is set to <code class="docutils literal notranslate"><span class="pre">&quot;/tmp/my-data-folder&quot;</span></code>, and you
call <code class="docutils literal notranslate"><span class="pre">local_data_manager.require(&quot;path/to/image.jpg&quot;)</span></code>, it would check if
<code class="docutils literal notranslate"><span class="pre">&quot;/tmp/my-data-folder/path/to/image.jpg&quot;</span></code> exists, and if so return that complete path
(<code class="docutils literal notranslate"><span class="pre">&quot;/tmp/my-data-folder/path/to/image.jpg&quot;</span></code>), otherwise it raises an error.</p>
<dl class="simple">
<dt>In order of precedence, the local data folder is set by</dt><dd><ol class="arabic simple">
<li><p>Passing in the path to the constructor of <code class="docutils literal notranslate"><span class="pre">LocalDataManager</span></code></p></li>
<li><p>Setting the <code class="docutils literal notranslate"><span class="pre">L5KIT_DATA_FOLDER</span></code> environment variable.</p></li>
</ol>
</dd>
</dl>
<dl class="py method">
<dt id="l5kit.data.LocalDataManager.require">
<code class="sig-name descname">require</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">key</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; str<a class="headerlink" href="#l5kit.data.LocalDataManager.require" title="Permalink to this definition">¶</a></dt>
<dd><p>Require checks whether the file with the given key is present in the local data folder, if it is not it
raises an error. Returns the path to the file otherwise.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>key</strong> (<em>str</em>) – Path from the data folder where the file or folder should be present.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>str – Filepath including the data folder where required key is present.</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt id="l5kit.data.filter_agents_by_frame">
<code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">filter_agents_by_frame</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">all_agents</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">frame</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="headerlink" href="#l5kit.data.filter_agents_by_frame" title="Permalink to this definition">¶</a></dt>
<dd><p>Given all agents, returns those in the given frame.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>all_agents</strong> (<em>np.ndarray</em>) – agents array</p></li>
<li><p><strong>frame</strong> (<em>np.ndarray</em>) – frame whose agent_index_interval will be used to slice <code class="docutils literal notranslate"><span class="pre">all_agents</span></code>.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>np.ndarray – An array of agents that is a subset of <cite>all_agents</cite></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="l5kit.data.filter_agents_by_labels">
<code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">filter_agents_by_labels</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">agents</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">threshold</span><span class="p">:</span> <span class="n">float</span> <span class="o">=</span> <span class="default_value">0.5</span></em><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="headerlink" href="#l5kit.data.filter_agents_by_labels" title="Permalink to this definition">¶</a></dt>
<dd><p>Filters an agents array, keeping those agents that meet the threshold.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>agents</strong> (<em>np.ndarray</em>) – Agents array</p>
</dd>
<dt class="field-even">Keyword Arguments</dt>
<dd class="field-even"><p><strong>threshold</strong> (<em>float</em>) – probability threshold for filtering (default: {0.5})</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>np.ndarray – A subset of input <code class="docutils literal notranslate"><span class="pre">agents</span></code> array.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="l5kit.data.get_agent_by_track_id">
<code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">get_agent_by_track_id</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">all_agents</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">frame</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">track_id</span><span class="p">:</span> <span class="n">int</span></em><span class="sig-paren">)</span> &#x2192; Optional<span class="p">[</span>numpy.ndarray<span class="p">]</span><a class="headerlink" href="#l5kit.data.get_agent_by_track_id" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the agent object (np.ndarray) of a given track_id in a frame.
Return None if the agent is not among those in the frame.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>all_agents</strong> (<em>np.ndarray</em>) – agents array</p></li>
<li><p><strong>frame</strong> (<em>np.ndarray</em>) – given frame</p></li>
<li><p><strong>track_id</strong> (<em>int</em>) – agent track id to select</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Optional[np.ndarray] – Selected agent, or None if this agent is not present in given frame.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="l5kit.data.get_combined_scenes">
<code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">get_combined_scenes</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">scenes</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="headerlink" href="#l5kit.data.get_combined_scenes" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes as input an np.ndarray or zarr array with scenes, and combines scenes that follow up
eachother perfectly (i.e. from a single recording by the same host). Returns an np.ndarray
of combined scenes.</p>
<blockquote>
<div><dl class="simple">
<dt>Arguments:</dt><dd><p>scenes (np.ndarray): scenes</p>
</dd>
<dt>Returns:</dt><dd><p>np.ndarray – combined scenes where followup scenes have been merged.</p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="py function">
<dt id="l5kit.data.load_pose_to_ecef">
<code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">load_pose_to_ecef</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="headerlink" href="#l5kit.data.load_pose_to_ecef" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads the pose to ECEF transformation matrix.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>4x4 transformation matrix of dtype <code class="docutils literal notranslate"><span class="pre">np.float64</span></code>.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>np.ndarray</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="l5kit.data.load_semantic_map">
<code class="sig-prename descclassname">l5kit.data.</code><code class="sig-name descname">load_semantic_map</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">semantic_map_path</span><span class="p">:</span> <span class="n">str</span></em><span class="sig-paren">)</span> &#x2192; dict<a class="headerlink" href="#l5kit.data.load_semantic_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads and does preprocessing of given semantic map in binary proto format.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>semantic_map_path</strong> (<em>str</em>) – The path of the semantic map file to load, a binary proto.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A dict containing the semantic map contents.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>

<div class="section" id="subpackages">
<h2>Subpackages<a class="headerlink" href="#subpackages" title="Permalink to this headline">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.proto.html">l5kit.data.proto package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="l5kit.data.proto.html#submodules">Submodules</a><ul>
<li class="toctree-l3"><a class="reference internal" href="l5kit.data.proto.road_network_pb2.html">l5kit.data.proto.road_network_pb2 module</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.combine.html">l5kit.data.combine module</a></li>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.filter.html">l5kit.data.filter module</a></li>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.labels.html">l5kit.data.labels module</a></li>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.local_data_manager.html">l5kit.data.local_data_manager module</a></li>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.map.html">l5kit.data.map module</a></li>
<li class="toctree-l1"><a class="reference internal" href="l5kit.data.zarr_dataset.html">l5kit.data.zarr_dataset module</a></li>
</ul>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="l5kit.data.proto.html" class="btn btn-neutral float-right" title="l5kit.data.proto package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="../api_reference.html" class="btn btn-neutral float-left" title="API Reference" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        
        &copy; Copyright 2020, Lyft Level 5

    </p>
  </div>
    
    
    
    Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>